<?php
Class QuestionsController extends Controller{
    
    function actionForm(){
        $questions = new Questions();
        $choice = new Choice();
            
            if(isset($_POST["Questions"])){
                $questions->_attributes = $_POST["Questions"];
                $questions->ques_created = date('Y-m-d H:i:s');
                
                $choice->choice1 = $_POST["Choice"]["choice1"];
                $choice->choice2 = $_POST["Choice"]["choice2"];
                $choice->choice3 = $_POST["Choice"]["choice3"];
                $choice->choice4 = $_POST["Choice"]["choice4"];
                $choice->choice5 = $_POST["Choice"]["choice5"];

            if ($questions->save()){
                $choice->save();
                $this->redirect(array("index"));
            }
        }
        $this->render("Form", array(
            "questions" => $questions,
            "choice" => $choice
        ));
    }

    public function actionIndex() {
        
        $ques = new Questions();
        //$ques = new CActiveDataProvider($questions);
        $this->render("Questions", array(
            "ques" => $ques
        ));
    }
    
    
    }

?>
